#pragma once

#include "gm_sc_dev.h"
#include <middleware/gm_api/skfapi.h>

class gm_sc_dev_mgr
{
public:
	gm_sc_dev_mgr(void);
	~gm_sc_dev_mgr(void);

	ULONG add_dev(gm_sc_dev* sc_dev);

	gm_sc_dev* get_dev_by_handle(HANDLE devHandle);

	ULONG remove_dev(gm_sc_dev* sc_dev);

	gm_sc_dev* get_first_dev();

	gm_sc_dev* get_next_dev();

	void clear();

	gm_sc_digest * find_digest( HANDLE hHash, gm_sc_dev *& pDev);

	gm_sc_app * find_app( HAPPLICATION hApplication,gm_sc_dev *& pDev);

	gm_sc_key * find_key( HANDLE hkey, HANDLE * hDev, ULONG * appId, ULONG * contId );

	gm_sc_key * find_key( HANDLE hkey, gm_sc_dev *& pDev, gm_sc_app *& pApp, gm_sc_cont *& pContainer);

	gm_sc_mac * find_mac( HANDLE hMac, gm_sc_dev *& pDev, gm_sc_app *& pApp, gm_sc_cont *& pContainer);

	gm_sc_cont * find_container(HANDLE hContainer, gm_sc_dev *& pDev, gm_sc_app *& pApp);


private:
	mk_node_list _sc_dev_list;
	mk_node		*_curr_pos;
};
